The Use of Overloading in Java Programs
نویسندگان
چکیده
Method overloading is a controversial language feature, especially in the context of Object Oriented languages, where its interaction with overriding may lead to confusing semantics. One of the main arguments against overloading is that it can be abused by assigning the same identity to conceptually different methods. This paper describes a study of the actual use of overloading in JAVA. To this end, we developed a taxonomy of classification of the use of overloading, and applied it to a large JAVA corpus comprising more than 100,000 user defined types. We found that more than 14% of the methods in the corpus are overloaded. Using sampling and evaluation by human raters we found that about 60% of overloaded methods follow one of the “non ad hoc use of overloading patterns” and that additional 20% can be easily rewritten in this form. The most common pattern is the use of overloading as an emulation of default arguments, a mechanism which does not exist in JAVA.
منابع مشابه
A Safe Implementation of Dynamic Overloading in Java-Like Languages
We present a general technique for extending Java-like languages with dynamic overloading, where method selection depends on the dynamic type of the parameter, instead of just the receiver. To this aim we use a core Java-language enriched with encapsulated multi-methods and dynamic overloading. Then we define an algorithm which translates programs to standard Java code using only basic mechanis...
متن کاملJava Modular Extension for Operator Overloading
The paper introduces a modular extension (plugin) for Java language compilers and Integrated Development Environments (IDE) which adds operator overloading feature to Java language while preserving backward compatibility. The extension use the idea of library-based language extensibility similar to SugarJ[1]. But unlike most language extensions, it works directly inside the compiler and does no...
متن کاملKeyword- and Default- Parameters in JAVA
Overloading is a highly controversial programming language mechanism by which different methods of the same class are allowed to bear the same name. Despite the criticism, JAVA programmers make extensive use of this mechanism—not just because it is available, but also because the language does not provide an alternative for defining multiple constructors, and because it is useful for expressing...
متن کاملA software system for laboratory experiments in image processing
Laboratory experiments for image processing courses are usually software implementations of processing algorithms, but students of image processing come from diverse backgrounds with widely differing software experience. To avoid learning overhead, the software system should be easy to learn and use, even for those with no exposure to mathematical programming languages or object-oriented progra...
متن کاملType inference for MLj
MLj is an extension of the Standard ML language which allows interoperation with Java. It has a type system which combines ML’s parametric polymorphism and type inference with Java’s subtyping (class hierarchy) and arbitrary overloading of methods. In this paper, we discuss some of the difficulties in implementing type inference for MLj and outline our progress on the implementation. In particu...
متن کامل